<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%course_select}}".
 *
 * @property int $id 选课序号
 * @property int $user_id 用户ID
 * @property string $course_id 课程ID
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class CourseSelect extends Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%course_select}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'course_id'], 'required'],
            [['user_id', 'status', 'created_at', 'updated_at'], 'integer'],
            [['course_id'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '选课序号',
            'user_id' => '用户', //用户ID
            'course_id' => '课程', //课程ID
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

    /**
     * 得到用户信息
     * @name: getUser
     * @return
     * @author: rickeryu <lhyfe1987@163.com>
     * @time: 2017/12/20 13:29
     */
    public function getUser(){
        $result = $this->hasOne(User::className(),['user_id'=>'id']);
        return $result;
    }
}
